<template>
    
</template>
<script>
export default {
    name: "giteeCallback",
    data() {
        return {
            authCallback: {
                platform:"gitee",
                code: "",
                state: ""
            }
        }
    },
    mounted() {
        var accessToken = this.$utils.getUrlKey("access_token");
        var code = this.$utils.getUrlKey("code");
        var state = this.$utils.getUrlKey("state");
        this.authCallback.code=code
        this.authCallback.state=state
        //server-side模式
        if (code && typeof code != "undefined") {
            console.log("server-side模式:" + code);
            //获取到token就是已经登录了
            var token = this.$store.getters.token;
            if (token && typeof token != "undefined") {
                this.$router.push("/");
            }
            //未登录则执行登录
            else {

                this.$store.dispatch("user/authCodelogin", this.authCallback).then(() => {
                    location.reload();
                });
            }
        }
    },
};
</script>

<style>

</style>